package com.ruoyi.evalution.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.evalution.domain.LabEvalutionUser;
import com.ruoyi.evalution.service.ILabEvalutionUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评测人员Controller
 * 
 * @author winner pan
 * @date 2022-04-15
 */
@RestController
@RequestMapping("/evalution/user")
public class LabEvalutionUserController extends BaseController
{
    @Autowired
    private ILabEvalutionUserService labEvalutionUserService;

    /**
     * 查询评测人员列表
     */
    //@PreAuthorize("@ss.hasPermi('evalution:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabEvalutionUser labEvalutionUser)
    {
        startPage();
        List<LabEvalutionUser> list = labEvalutionUserService.selectLabEvalutionUserList(labEvalutionUser);
        return getDataTable(list);
    }

    /**
     * 导出评测人员列表
     */
   // @PreAuthorize("@ss.hasPermi('evalution:user:export')")
    @Log(title = "评测人员", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabEvalutionUser labEvalutionUser)
    {
        List<LabEvalutionUser> list = labEvalutionUserService.selectLabEvalutionUserList(labEvalutionUser);
        ExcelUtil<LabEvalutionUser> util = new ExcelUtil<LabEvalutionUser>(LabEvalutionUser.class);
        return util.exportExcel(list, "user");
    }

    /**
     * 获取评测人员详细信息
     */
   // @PreAuthorize("@ss.hasPermi('evalution:user:query')")
    @GetMapping(value = "/{evalutionUserId}")
    public AjaxResult getInfo(@PathVariable("evalutionUserId") Long evalutionUserId)
    {
        return AjaxResult.success(labEvalutionUserService.selectLabEvalutionUserById(evalutionUserId));
    }

    /**
     * 新增评测人员
     */
   // @PreAuthorize("@ss.hasPermi('evalution:user:add')")
    @Log(title = "评测人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabEvalutionUser labEvalutionUser)
    {
        return toAjax(labEvalutionUserService.insertLabEvalutionUser(labEvalutionUser));
    }

    /**
     * 修改评测人员
     */
   // @PreAuthorize("@ss.hasPermi('evalution:user:edit')")
    @Log(title = "评测人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabEvalutionUser labEvalutionUser)
    {
        return toAjax(labEvalutionUserService.updateLabEvalutionUser(labEvalutionUser));
    }

    /**
     * 删除评测人员
     */
   // @PreAuthorize("@ss.hasPermi('evalution:user:remove')")
    @Log(title = "评测人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evalutionUserIds}")
    public AjaxResult remove(@PathVariable Long[] evalutionUserIds)
    {
        return toAjax(labEvalutionUserService.deleteLabEvalutionUserByIds(evalutionUserIds));
    }
}
